package com.winexpress.entity;

import com.winexpress.helper.AESEncryptor;
import com.winexpress.helper.Config;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;

@Entity
public class Customer extends User implements Serializable {

    private String creditCardNumber;
    private String address;
    private String facebookID;
    private String gooogleID;
    private boolean subscribed;

    public String getGooogleID() throws Exception {
        return gooogleID;
    }

    public void setGooogleID(String gooogleID) throws Exception {
        this.gooogleID = gooogleID;
    }

    public String getCreditCardNumber() throws Exception {
        if (creditCardNumber != null) {
            return AESEncryptor.decrypt(Config.seed, creditCardNumber);
        }
        return "";
    }

    public String getFacebookID() throws Exception {
        return facebookID;
    }

    public void setFacebookID(String facebookID) throws Exception {
        this.facebookID = facebookID;
    }

    public void setCreditCardNumber(String creditCardNumber) throws Exception {
        this.creditCardNumber = AESEncryptor.encrypt(Config.seed, creditCardNumber);
    }

    public String getAddress() throws Exception {
        if (address != null) {
            return AESEncryptor.decrypt(Config.seed, address);
        }
        return "";
    }

    public void setAddress(String address) throws Exception {
        if (address.isEmpty()) {
            address = "";
        }
        this.address = AESEncryptor.encrypt(Config.seed, address);
    }

    public boolean isSubscribed() {
        return subscribed;
    }

    public void setSubscribed(boolean subscribed) {
        this.subscribed = subscribed;
    }

}
